#ifndef _IO_H_
#define _IO_H_

#include "main.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "driver/gpio.h"

#define LED_1			(38)
#define LED_2			(37)
#define LED_3			(36)
#define LED_4			(35)
#define LED_5			(8)
#define	LED1_Ctl(x)		gpio_set_level(LED_1,x)
#define	LED2_Ctl(x)		gpio_set_level(LED_2,x)
#define	LED3_Ctl(x) 	gpio_set_level(LED_3,x)
#define	LED4_Ctl(x) 	gpio_set_level(LED_4,x)
#define	LED5_Ctl(x) 	gpio_set_level(LED_5,x)
#define	LED1_ON			LED1_Ctl(0)
#define	LED1_OFF		LED1_Ctl(1)
#define	LED2_ON			LED2_Ctl(0)
#define	LED2_OFF		LED2_Ctl(1)
#define	LED3_ON			LED3_Ctl(0)
#define	LED3_OFF		LED3_Ctl(1)
#define	LED4_ON			LED4_Ctl(0)
#define	LED4_OFF		LED4_Ctl(1)
#define	LED5_ON			LED5_Ctl(0)
#define	LED5_OFF		LED5_Ctl(1)
#define	LED1_TWK_ON		(LedPm.number|= (1<<0))
#define	LED1_TWK_OFF	(LedPm.number&= ~(1<<0))
#define	LED2_TWK_ON		(LedPm.number|= (1<<1))
#define	LED2_TWK_OFF	(LedPm.number&= ~(1<<1))
#define	LED3_TWK_ON		(LedPm.number|= (1<<2))
#define	LED3_TWK_OFF	(LedPm.number&= ~(1<<2))
#define	LED4_TWK_ON		(LedPm.number|= (1<<3))
#define	LED4_TWK_OFF	(LedPm.number&= ~(1<<3))
#define	LED5_TWK_ON		(LedPm.number|= (1<<4))
#define	LED5_TWK_OFF	(LedPm.number&= ~(1<<4))

#define Beep_IO			(2)
#define	Beep_Ctl(x) 	gpio_set_level(Beep_IO,x)

#define Pwr_IO			(9)
#define	Pwr_Ctl(x)  	gpio_set_level(Pwr_IO,x)
#define	Pwr_ON			Pwr_Ctl(1)
#define	Pwr_OFF			Pwr_Ctl(0)

#define Chg_IO			(10)
#define	Chg_Get 		gpio_get_level(Chg_IO)
#define ChgFull_IO		(1)
#define	ChgFull_Get 	gpio_get_level(ChgFull_IO)

#define Btu_IO			(15)
#define	Btu_Get 		gpio_get_level(Btu_IO)

#define Pluse_IO 		(16)
#define	Pluse_Get 		gpio_get_level(Pluse_IO)

extern uint8_t PrintEnd;
extern uint32_t INPulse_count;

void IO_Init(void);
void Led_set(int sta);
void Led_McuOnSta(void);
void Beep_set(uint16_t tim);
void BeepExp_set(uint16_t tim,uint8_t cnt);

#endif

